<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>微博评论列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
</head>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">

            <fieldset class="table-search-fieldset">
                <legend>搜索信息</legend>
                <div style="margin: 10px 10px 10px 10px">
                    <form class="layui-form layui-form-pane" action="">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">关键词</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="keywords" id="keywords" autocomplete="off"
                                        class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button type="submit" class="layui-btn layui-btn-primary" lay-submit
                                    lay-filter="search"><i class="layui-icon"></i> 搜 索</button>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>


            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>


        </div>
    </div>
    <script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
    <script>
        layui.use(['form', 'table'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table;

            table.render({
                elem: '#currentTableId',
                url: '/api/business/getCommentList/',
                defaultToolbar: ['filter', 'exports', 'print', {
                    title: '提示',
                    layEvent: 'LAYTABLE_TIPS',
                    icon: 'layui-icon-tips'
                }],
                cols: [[
                    {
                        field: 'comment', minWidth: 1000, title: '评论内容', templet: function (d) {
                            // 确保后端返回的数据中包含 comment_url 字段
                            return '<a href="' + d.weibo_url + '" target="_blank" style="color: blue;">' + d.comment + '</a>';
                        }
                    },
                    { field: 'screen_name', width: 200, title: '用户昵称' },
                    { field: 'like_count', width: 80, title: '喜欢的数量', sort: true },
                    { field: 'floor_number', width: 80, title: '楼层数', sort: true },
                    { field: 'follow_count', width: 80, title: '回复数', sort: true },
                ]],
                limits: [10, 15, 20, 25, 50, 100],
                limit: 15,
                page: true
            });

            // 监听搜索操作
            form.on('submit(search)', function (data) {
                var result = JSON.stringify(data.field);
                keywords = data.field.keywords

                //执行搜索重载
                table.reload('currentTableId', {
                    page: {
                        curr: 1
                    }
                    , where: {
                        'keywords': keywords,
                    }
                }, 'data');

                return false;
            });

        });
    </script>
    <script>

    </script>

</body>

</html>